package server.business.http;

import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.FullHttpResponse;

import java.util.List;
import java.util.Map;

import server.business.entity.Notice;
import server.business.service.HttpServiceFactory;
import server.business.service.IHttpService;

import com.alibaba.fastjson.JSON;
import com.core.rest.AbstractHttpHandler;

public class CurrentNoticeHandler extends AbstractHttpHandler implements Cloneable {

    @Override
    protected Object clone() throws CloneNotSupportedException {

        return super.clone();
    }

    @Override
    protected void getData(Map<String, String> params, ChannelHandlerContext ctx) {

        String text = "";

        IHttpService service = HttpServiceFactory.getService();
        //String notice = params.get("notice");

        List<Notice> list = service.showCurrentList();

        text = JSON.toJSONString(list, true);

        FullHttpResponse response = wrapContent(text);

        sendResponse(ctx, response);

    }

    @Override
    protected void postData(Map<String, String> params, ChannelHandlerContext ctx) {
        // TODO Auto-generated method stub

    }

    @Override
    protected void deleteData(Map<String, String> params, ChannelHandlerContext ctx) {
        // TODO Auto-generated method stub

    }

    @Override
    protected void updateData(Map<String, String> params, ChannelHandlerContext ctx) {
        // TODO Auto-generated method stub

    }

    @Override
    public AbstractHttpHandler deepCopy() {

        AbstractHttpHandler httpHandler = null;

        try {

            httpHandler = (AbstractHttpHandler)(this.clone());

        } catch (CloneNotSupportedException e) {

            e.printStackTrace();
        }

        return httpHandler;
    }

}
